/*    */ package com.lmpop.updateHtml.parseXml;
/*    */ 
/*    */ import java.io.BufferedReader;
/*    */ import java.io.FileInputStream;
/*    */ import java.io.IOException;
/*    */ import java.io.InputStreamReader;
/*    */ import java.io.PrintStream;
/*    */ import java.net.URL;
/*    */ import java.util.Properties;
/*    */ 
/*    */ public class Config
/*    */ {
/*    */   private Properties props;
/*    */   private String classpath;
/*    */ 
/*    */   public Config()
/*    */   {
/* 17 */     this.props = new Properties();
/* 18 */     this.classpath = classPath();
/* 19 */     init();
/*    */   }
/*    */ 
/*    */   public Config(String properName) {
/* 23 */     this.props = new Properties();
/* 24 */     this.classpath = classPath();
/* 25 */     init(properName);
/*    */   }
/*    */ 
/*    */   public void init() {
/* 29 */     init("config.properties");
/*    */   }
/*    */ 
/*    */   public void init(String properName)
/*    */   {
/* 34 */     String filePath = this.classpath + properName;
/* 35 */     System.out.println(filePath);
/* 36 */     BufferedReader in = null;
/*    */     try {
/* 38 */       if (!System.getProperties().getProperty("file.encoding").equals("UTF-8"))
/* 39 */         in = new BufferedReader(new InputStreamReader(new FileInputStream(filePath), "UTF-8"));
/*    */       else {
/* 41 */         in = new BufferedReader(new InputStreamReader(new FileInputStream(filePath)));
/*    */       }
/*    */ 
/* 44 */       this.props.load(in);
/*    */     } catch (Exception e) {
/* 46 */       e.printStackTrace();
/*    */     } finally {
/*    */       try {
/* 49 */         in.close();
/*    */       } catch (IOException e) {
/* 51 */         e.printStackTrace();
/*    */       }
/*    */     }
/*    */   }
/*    */ 
/*    */   public static String classPath() {
/* 57 */     String basepath = Thread.currentThread().getContextClassLoader().getResource("").toString();
/* 58 */     if ((basepath.startsWith("/")) || (!"Windows".equals(System.getProperty("os.name")))) {
/* 59 */       return basepath.substring(5, basepath.length());
/*    */     }
/* 61 */     return basepath.substring(6, basepath.length());
/*    */   }
/*    */ 
/*    */   public String getString(String key) {
/*    */     try {
/* 66 */       String value = "";
/* 67 */       if (this.props.getProperty(key) != null) {
/* 68 */         value = this.props.getProperty(key);
/*    */       }
/* 70 */       return value;
/*    */     } catch (Exception e) {
/* 72 */       e.printStackTrace();
/* 73 */     }return "";
/*    */   }
/*    */ 
/*    */   public static void main(String[] args)
/*    */   {
/* 78 */     System.out.println(System.getProperty("os.name"));
/*    */   }
/*    */ }

/* Location:           F:\电商\commons-utils.jar
 * Qualified Name:     com.lmpop.updateHtml.parseXml.Config
 * JD-Core Version:    0.6.0
 */